package net.minecraft.src;

import java.util.ArrayList;
import java.util.Random;

import net.minecraft.src.forge.ForgeHooks;
import net.minecraft.src.forge.IShearable;

public class BlockTallGrass extends BlockFlower implements IShearable
{
    protected BlockTallGrass(int i, int j)
    {
        super(i, j);
        float f = 0.4F;
        setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.8F, 0.5F + f);
    }

    public int getBlockTextureFromSideAndMetadata(int i, int j)
    {
        if (j == 1)
        {
            return blockIndexInTexture;
        }
        if (j == 2)
        {
            return blockIndexInTexture + 16 + 1;
        }
        if (j == 0)
        {
            return blockIndexInTexture + 16;
        }
        else
        {
            return blockIndexInTexture;
        }
    }

    public int getBlockColor()
    {
        double d = 0.5D;
        double d1 = 1.0D;
        return ColorizerGrass.getGrassColor(d, d1);
    }

    public int getRenderColor(int i)
    {
        if (i == 0)
        {
            return 0xffffff;
        }
        else
        {
            return ColorizerFoliage.getFoliageColorBasic();
        }
    }

    public int colorMultiplier(IBlockAccess iblockaccess, int i, int j, int k)
    {
        int l = iblockaccess.getBlockMetadata(i, j, k);
        if (l == 0)
        {
            return 0xffffff;
        }
        else
        {
            return iblockaccess.getWorldChunkManager().getBiomeGenAt(i, k).getGrassColorAtCoords(iblockaccess, i, j, k);
        }
    }

    public int idDropped(int i, Random random, int j)
    {
        return -1;
    }

    public int quantityDroppedWithBonus(int i, Random random)
    {
        return 1 + random.nextInt(i * 2 + 1);
    }

    @Override
    public ArrayList<ItemStack> getBlockDropped(World world, int i, int j, int k, int md, int fortune)
    {
    	ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
    	if (world.rand.nextInt(8) != 0)
    	{
    		return ret;
    	}
    	
    	ItemStack item = ForgeHooks.getGrassSeed(world);
    	if (item != null)
    	{
    		ret.add(item);
    	}
    	return ret;
    }
    
    public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l)
    {
        super.harvestBlock(world, entityplayer, i, j, k, l);
    }

    @Override
    public boolean isShearable(ItemStack item, World world, int X, int Y, int Z) 
    {
        return true;
    }

    @Override
    public ArrayList<ItemStack> onSheared(ItemStack item, World world, int X, int Y, int Z, int fortune) 
    {
        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
        ret.add(new ItemStack(this, 1, world.getBlockMetadata(X, Y, Z)));
        return ret;
    }
}
